Skip to main content

Quick Start

First, add the onGiftmeReady helper snippet from the Installation page.

window.onGiftmeReady(async ({ giftmeMakePayment, giftmeGetAuthCode, isMiniStoreContext }) => {
if (!isMiniStoreContext()) {
console.warn('Not inside Giftme — falling back to standard checkout.');
// render your regular web checkout instead…
return;
}

/**
* 1. Ask the app for an auth token
* - returns a short-lived token that you can use to authenticate API requests
*/
const authResult = await giftmeGetAuthCode({ miniStoreId: 'ABC123' });
if (authResult.status === 'SUCCESS') {
const { token } = authResult.payload;
await fetch('/api/oauth/token', { method: 'POST', body: JSON.stringify({ token }) });
}

/**
* 2. Kick off an in-app payment
*/
const paymentResult = await giftmeMakePayment({ orderToken: 'ORDER_XXXXXXXX' });
if (paymentResult.status === 'SUCCESS') {
// Payment completed successfully
const data = paymentResult.payload;
} else if (paymentResult.status === 'CANCELLED') {
// User cancelled the payment
} else {
// Payment failed
console.error(paymentResult.payload.message);
}
});